import '@/assets/css/reset.scss' // 引入全局样式
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant from 'vant'
import '@vant/touch-emulator'
import ElementUI from 'element-ui'
import Print from 'vue-print-nb'

import UmyUi from 'umy-ui'
import 'umy-ui/lib/theme-chalk/index.css';// 引入样式
Vue.use(UmyUi);

// 加载进度
import 'vant/lib/index.css'
// import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/css/element-variables.scss'
import 'nprogress/nprogress.css' // nprogress的样式
import '@/assets/css/base.scss' // 引入全局样式
import base from '@/base.js'
// import '@/common/js/rem.js'
import http from '@/common/js/api.js'
import globalCom from '@/components/global/index.js'
import api from '@/api'
import '@/assets/css/iconfont/iconfont.css'
import '@/common/js/directive.js'
import VueSeamlessScroll from 'vue-seamless-scroll'
import VueAnimateNumber from 'vue-animate-number'

// 图片懒加载
import { Lazyload } from 'vant'
import VueAMap from 'vue-amap'
// 时间轴
import LightTimeline from 'vue-light-timeline'
import { querydata, selectdata } from '@/common/js/dataDictionary.js'
import page from '@common/js/pagination.js'



Vue.use(LightTimeline)
Vue.use(Print)
// Vue.use(FSnakeTimeline);
Vue.use(VueAMap)
Vue.use(VueSeamlessScroll)
Vue.use(VueAnimateNumber)
VueAMap.initAMapApiLoader({
  // key: 'ce682950de25cdc66e2cea1923d1e5c6',
  key: 'e4b5cc3ac48efcdf4de676ffa386f11f',
  plugin: ['AMap.PlaceSearch', 'AMap.TruckDriving', 'AMap.Driving', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'AMap.Geocoder', 'AMap.Geolocation', 'AMap.MarkerClusterer'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4',
  uiVersion: '1.0'
})
Vue.use(Lazyload)
Vue.use(base)
Vue.use(ElementUI, { size: 'mini' })
Vue.use(Vant)
Vue.use(globalCom) // 注册全局组件
Vue.prototype.$API = api
Vue.config.productionTip = false
Vue.prototype.$EventBus = new Vue() // 多级菜单参数
Vue.prototype.$http = http
Vue.prototype.querydata = querydata
Vue.prototype.selectdata = selectdata
Vue.prototype.$paginationSize = page.pageList
Vue.prototype.$defaultPage = page.defaultPage

// 配置钉钉扫码登录
let parentUrl = document.location.origin + '/ly-jx-pcr/#/login'
Vue.prototype.$userLoginUrl = process.env.NODE_ENV === 'production' ? encodeURIComponent(parentUrl) : encodeURIComponent(parentUrl)
// 路由守卫
router.beforeEach((to, from, next) => {
	
  if (to.meta.title) {
    document.title = to.meta.title + '·重庆铃宇铃宇供应链·数字化智能管理平台'
    // 配置共用页面，菜单栏选中问题处理 示例
    // this.$router.push({
    //   path: '/stockManage/appointmentManage/appointment',
    //   query: {
    //     activeMenu: '/wms/stockManage/appointmentManage' ********
    //   }
    // })
		if(to.meta.keepAlive){
			store.dispatch('addKeepViews',to.name)
			to.meta.isTagOpen=true
		}
		
    if (to.query.activeMenu) {
      to.meta.activeMenu = to.query.activeMenu
    }
  }
  next()
})
router.onError(error => {
  const pattern = /Loading chunk (\d)+ failed/g
  const isChunkLoadFailed = error.message.match(pattern)
  const targetPath = router.history.pending.fullPath
  if (isChunkLoadFailed) {
    router.replace(targetPath)
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
